package com.idcf.boathouse.account.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.idcf.boathouse.account.entity.OrderInvoice;
import com.idcf.boathouse.account.mapper.OrderInvoiceMapper;
import com.idcf.boathouse.account.param.OrderInvoiceCreateParam;
import com.idcf.boathouse.account.service.OrderInvoiceService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 订单发票表(OrderInvoice)表服务实现类
 *
 * @author isaiah.wang
 * @since 2021-06-27 10:50:48
 */
@Service("orderInvoiceService")
public class OrderInvoiceServiceImpl extends ServiceImpl<OrderInvoiceMapper, OrderInvoice> implements OrderInvoiceService {

    @Autowired
    private OrderInvoiceMapper orderInvoiceMapper;

    /**
     * 创建电子票据
     *
     * @param orderInvoice
     * @return java.lang.String
     * @author Isaiah.Wang
     * @date 2021/6/27 上午11:41
     */
    @Override
    public String createOrderInvoice(OrderInvoiceCreateParam orderInvoice) {
        OrderInvoice invoice = new OrderInvoice();
        try {
            BeanUtils.copyProperties(orderInvoice, invoice);
            int insert = orderInvoiceMapper.insert(invoice);
            if (insert > 0) {
                return "添加成功！";
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return "添加失败！";
    }
}
